package com.liy.cloud.auth.client.utils;

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

public class RequestUtil {

    private static final ObjectMapper mapper = new ObjectMapper();

    public static String map2urlparam(Map<String, Object> map) {
        if (map == null) {
            return "";
        } else {
            StringBuffer sb = new StringBuffer();
            Iterator var2 = map.entrySet().iterator();

            while(var2.hasNext()) {
                Entry<String, Object> entry = (Entry)var2.next();
                sb.append("&");
                sb.append((String)entry.getKey() + "=" + entry.getValue());
            }

            return sb.toString();
        }
    }


    public static String vo2urlparam(Object obj) {
        Map<String, Object> resultMap = (Map)mapper.convertValue(obj, Map.class);
        StringBuffer sb = new StringBuffer();
        Iterator var3 = resultMap.entrySet().iterator();

        while(var3.hasNext()) {
            Entry<String, Object> entry = (Entry)var3.next();
            sb.append("&");
            sb.append((String)entry.getKey() + "=" + entry.getValue());
        }

        return sb.toString();
    }

    static {
        mapper.setSerializationInclusion(Include.NON_NULL);
    }
}
